package com.mkh.st.common.core.serializer;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.google.common.base.Joiner;

import java.io.IOException;
import java.util.List;

/**
 * Author: xhx
 * Date: 2021/10/26 5:11 下午
 * FileName: String2ListSerializer
 * Description:
 */
public class String2ListSerializer extends JsonSerializer<String> {

	@Override
	public void serialize(String string, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
		String[] result =  StrUtil.split(string, ",");
		jsonGenerator.writeArray(result, 0, result.length);
	}
}
